// import useAuthButtons from "@/hooks/useAuthButtons";
import { Button, DatePicker, GetProps, Space, Modal } from "antd";
import { useEffect, useRef, useState } from "react";
import ButtonPer from "@/components/ButtonPer";
import FormGenerator from "@/components/hz-module/FormGenerator";
// import { FormConfigItem } from "@/types/global";
import dayjs from "dayjs";
// import customParseFormat from "dayjs/plugin/customParseFormat";
import { formConfig } from "./config";

const Home = () => {
  // const {BUTTONS} = useAuthButtons()
  //   dayjs.extend(customParseFormat);

  // 表单初始值
  const initialValues = {
    name: "张三",
    gender: "male",
    // ... 其他表单项的初始值
    date: [dayjs().subtract(7, "day"), dayjs()],
  };
  const form = useRef(null);
  //   查询处理
  const handleFinish = (values: any) => {
    console.log("表单值:", values);
    // form.current.setFieldsValue(values)
    // 处理表单关闭
    // handleOk();
  };
  //   重置处理
  const handleReset = () => {
    console.log("reset");
  };

  // 弹窗
  const [visible, setVisible] = useState(false);
  // 确定处理
  const handleOk = () => {
    setVisible(false);
    // 这里可以添加提交表单逻辑
    const formValues = form.current?.getFieldsValue();
    console.log("表单值1:", formValues);
  };
  //   取消处理
  const handleCancel = () => {
    setVisible(false);
  };

  useEffect(() => {}, []);
  return (
    <>
      <div>Home</div>
      <Modal
        title="表单"
        open={visible}
        onOk={handleOk}
        onCancel={handleCancel}
      >
        <FormGenerator
          ref={form}
          isDialog={false}
          config={formConfig}
          values={initialValues}
          onFinish={handleFinish}
          onReset={handleReset}
        />
      </Modal>
      <FormGenerator
        ref={form}
        config={formConfig}
        values={initialValues}
        onFinish={handleFinish}
        onReset={handleReset}
      />
      <Space>
        <ButtonPer
          btn={"add"}
          Comp={
            <Button type="primary" onClick={() => setVisible(true)}>
              添加
            </Button>
          }
        />
        {/* {BUTTONS.includes('add') && <Button type="primary">添加</Button>} */}
      </Space>
    </>
  );
};

export default Home;
